<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>

  <style>
    * {
      margin: 0;
      padding: 0;
    }

    img {
      width: 520px;
      height: 280px;
    }

    ul, li {
      list-style: none;
    }

    ul {
      width: 640px;
      height: 280px;
      margin: 30px auto;
      border: 10px solid pink;
    }

    li {
      width: 160px;
      height: 100%;
      overflow: hidden;
      position: relative;
      float: left;
    }

  </style>
</head>
<body>
  <ul>
    <li><img src="./images/01.jpg" alt=""></li>
    <li><img src="./images/02.jpg" alt=""></li>
    <li><img src="./images/03.jpg" alt=""></li>
    <li><img src="./images/04.jpg" alt=""></li>
  </ul>
</body>
</html>
<script src='https://code.jquery.com/jquery-3.6.0.min.js'></script>
<script>
$('li').mouseenter(function(){
    $(this).siblings().finish().animate({width:40}).end().finish().animate({width:520});
})
$('ul').mouseleave(function(){
    $(this).children().animate({width:160}).finish();
})
</script>